<?php

class spTab extends spDiv
{
	private $ul;
	
	public function  __construct( $param=null )
	{
		parent::__construct( $param );
		parent::setClass( "spTab" );
		
		$this->ul = new spUnorderedList;
		parent::addChild( $this->ul );
	}
	
	/*
		$param : array(
			"title" => "mytitle"
		)
		
		returns container for tab
	*/
	
	public function add( $param )
	{
		// create a unique id
		$id = spGuid::v4();
		
		if ( isset($param["id"]) )
			$id = $param["id"];		
		
		$a = new spAnchor(array(
			"href" 		=> "#".$id,
			"content" 	=> $param["title"]
		));
		$li = new spListItem;
		$li->addChild( $a );
		$this->ul->addChild( $li );
	
		$container = new spDiv(array(
			"id" => $id
		));
		parent::addChild( $container );
		
		if ( isset($param["name_id"]) )
			$container->setElementNameId( $param["name_id"] );
		
		if ( isset($param["child"]) )
			$container->addChild( $param["child"] );
		
		return $container;
	}
}

?>